home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 354_01.zip / CESMOUSE.DOC < prev    next >
Text File  |  1993-04-01  |  56KB  |  1,849 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                              CESMouse Tools Library
  23.                                       With
  24.                           Complete Joystick Functions
  25.  
  26.  
  27.  
  28.                              Version 1.25 Shareware
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.           Copyright 1989, 1991. All Rights Reserved.
  52.  
  53.  
  54.           John F. Jarrett
  55.           Computer Engineering Services
  56.           Post Office Box 1222
  57.           Show Low, Arizona  85901
  58.           (602) 367-8996
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.                                TABLE OF CONTENTS
  73.  
  74.  
  75.  
  76.  
  77.           Program License ................................  1
  78.  
  79.           Introduction ...................................  2
  80.  
  81.           Installation ...................................  3
  82.  
  83.           Compiling with Power C .........................  4
  84.  
  85.           Compiling with Quick C and MS C 6.0 ............  5
  86.  
  87.           Compiling with Turbo C .........................  7
  88.  
  89.           Compiling With Quick Basic .....................  9
  90.  
  91.           Mouse Functions ................................ 11
  92.  
  93.           Example C Program For Mouse Functions .......... 20
  94.  
  95.           Joysticks ...................................... 21
  96.  
  97.           Joystick Functions ............................. 22
  98.  
  99.           Example C Source for Joystick Functions ........ 24
  100.  
  101.           Bug Report Form ................................ 25
  102.  
  103.           Product Registration ........................... 26
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.                                 PROGRAM LICENSE
  138.  
  139.  
  140.  
  141.          This manual,  as well as all  source code and object  code is
  142.          copyrighted material and is registered with the United States
  143.          Copyright Office, Copyright 1989, 1991.
  144.  
  145.          You, the  original purchaser, do  not own this  software, but
  146.          you have a non exclusive and non transferrable license to use
  147.          this software  on one machine. This  software is just  like a
  148.          book which cannot be read by another person at the same time.
  149.  
  150.          Therefore, you may use this software  on only one machine, or
  151.          one node of a network and make needed back up copies for your
  152.          own  archival use.  Site licenses  and  network licenses  are
  153.          available. Making copies  for another person is  not allowed,
  154.          and is a violation of the United States Copyright Law.
  155.  
  156.          You may combine the libraries, routines, functions and header
  157.          files into  your own  executable computer  programs that  you
  158.          write, as long as no source code of the functions within this
  159.          library are released and your program is compiled and linked,
  160.          without   paying  any   royalties   whatsoever  to   Computer
  161.          Engineering Services.
  162.  
  163.          Computer Engineering Services makes  no warranty expressed or
  164.          implied of any kind as to the suitability, merchantability or
  165.          applicability  of this  software  for  any purpose.  Computer
  166.          Engineering Services is  not liable for any  damages incurred
  167.          arrising out of the use or  inability to use this software by
  168.          you, others or otherwise.  Computer Engineering Services only
  169.          warrants  that the  magnetic  media  on which  this  software
  170.          resides is free from defects  in material and workmanship for
  171.          a  period  of ninety  days  IF  recorded and  distributed  by
  172.          Computer Engineering Services.
  173.  
  174.          Any reference  to Turbo C, Borland  C, Quick C,  MSC, MS-DOS,
  175.          MicroSoft Mouse or Quick Basic,  Power C, PC-DOS, Kraft Mouse
  176.          or Econo  Mouse, or others, are  for reference only,  and are
  177.          U.S.   Registered  Trademarks   of;  Borland   International,
  178.          Microsoft Corporation,  Mix Software,  International Business
  179.          Machines, (IBM), and Kraft Systems Inc.
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.                                        1
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.                                  INTRODUCTION
  204.  
  205.  
  206.          Ever  since learning  to  write programs  for  a computer,  I
  207.          learned the  value of  "tools" that  have assisted  me in  my
  208.          endeavors. Often I  purchase "tools" to assist me,  such as a
  209.          window tool kit,  communications tool kit, graphics  tool kit
  210.          and the like. There are many programmers tool kits available.
  211.  
  212.          My biggest problem has been coming up with the price for some
  213.          of the tool  kits and then having to  purchase more functions
  214.          and routines than I really want or need.
  215.  
  216.          To this end, I have had to write many of my own tool kits, or
  217.          canned functions that I can use in my day-to-day programming.
  218.          Since I have yet to see a library of only mouse functions all
  219.          by themselves,  I created just  that. The C.E.S.  Mouse Tools
  220.          Library. This library has over fifty functions that deal only
  221.          with  MicroSoft compatible  mice.  These  functions give  you
  222.          almost complete control over mouse  motion and sensing in all
  223.          of your programs.
  224.  
  225.          Since  nearly all  mice  sold  for IBM  compatible  computers
  226.          running  under  PC-DOS  or MS-DOS  are  compatible  with  the
  227.          defacto MicroSoft Mouse  Driver, almost any mouse  driver and
  228.          mouse will  function with these  routines. However  there are
  229.          some functions that  will only work with  the MicroSoft Mouse
  230.          Driver.
  231.  
  232.          Since we  are dealing  with secondary  (mouse) input  for the
  233.          computer, the joysticks have also  been a problem to program.
  234.          BASIC has  joystick functions,  but not C  or Pascal.  I have
  235.          thrown them  in for  C programmers,  because many  still play
  236.          with joysticks.
  237.  
  238.          The mouse and joystick routines are  written in C and are all
  239.          debugged and ready  for you to use. All of  the functions are
  240.          optimized for speed, not size. The functions are all designed
  241.          to be almost fool-proof so that a newcomer as well as an "old
  242.          timer" can easily  integrate these functions into  his or her
  243.          program.
  244.  
  245.          Presently,  the   library  is  compiled  for   the  following
  246.          compilers:
  247.  
  248.  
  249.          Borland Turbo C version 2.0, Turbo C++ and Borland C++
  250.          Microsoft Quick C version 1.0
  251.          MicroSoft C 6.0
  252.          Mix Power C Version 2.0
  253.  
  254.  
  255.          GOOD LUCK!
  256.  
  257.  
  258.          John F. Jarrett
  259.          Computer Engineering Services
  260.  
  261.  
  262.                                        2
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.                                  INSTALLATION
  270.  
  271.  
  272.  
  273.          Installation of the CES mouse  and joystick library functions
  274.          is  straight   forward.  The  include  files,   cesjoy.h  and
  275.          cesmouse.h should be copied into the "include" subdirectories
  276.          of MicroSoft  Quick C,  c 6.0  and Borland  Turbo C,  and the
  277.          library files,  mouseqcx.lib, mousemsx.lib  and mousetcx.lib,
  278.          should be placed into the "lib" subdirectories of each, and x
  279.          is the memory model of  the libraries. (The ShareWare version
  280.          ONLY includes the medium memory model).
  281.  
  282.          For Mix Power C, the include  and library files can be placed
  283.          in the same Power C directory with all of the other files. It
  284.          may also be a good idea, if  you have version 2.0 of Power C,
  285.          to compile the include, (.h) files  into the .hhh header file
  286.          using the fasthdr.exe utility supplied with version 2.0.
  287.  
  288.          On the distribution disk you will  find in the root directory
  289.          the  include   files,  cesjoy.h,   cesmouse.h,  cesmouse.bas,
  290.          cesmouse.doc, (this file),  and a read.me file  that includes
  291.          any  last  minute  changes  in  the  documentation  or  files
  292.          included on the disk.
  293.  
  294.          There  will be  directories for  each  make or  version of  a
  295.          supported compiler. These directories are;
  296.  
  297.  
  298.          POWER_C    includes libraries for version 2.0
  299.          QUICK_C    includes libraries for version 1.0 only
  300.          TURBO_C    includes libraries for version 2.0 only
  301.          EXAMPLES   contains source code for examples and executables
  302.          C_SOURCE   contains the C source code for the functions
  303.  
  304.  
  305.          The C  source for the  examples can  also be found  under the
  306.          SOURCE  subdirectory. The  manual  generally  only lists  the
  307.          Turbo C source code. Each file in the library as well as each
  308.          example is  written to  be as portable  as possible  for each
  309.          compiler, but differences do exist.
  310.  
  311.          The cesmouse.bas  file is an  example include file  for using
  312.          some of the library functions with QuickBasic and it is not a
  313.          supported feature of the CESMouse Tools Library.
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                        3
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.                             COMPILING WITH POWER C
  336.  
  337.  
  338.  
  339.          To compile  your programs  with the  CESmouse or  CESjoystick
  340.          libraries with Mix Power C is easy.
  341.  
  342.          Each of the library modules for  Power C follow the following
  343.          format:
  344.  
  345.  
  346.          mousepcX.lib (for mouse functions) or;
  347.          joypcX.lib (for joystick functions)
  348.  
  349.  
  350.          The "pc" included in the file name stands for Power C and the
  351.          X stands for the memory model, small, medium or large.
  352.  
  353.          The easiest way  to compile your programs with Power  C is to
  354.          first compile your file;
  355.  
  356.  
  357.          pc /ms mustest.c    to compile a small memory model program.
  358.  
  359.          Next link your file with the appropriate library;
  360.  
  361.          pcl mustest,,,mousepcs.lib;    "s" for small memory library.
  362.  
  363.  
  364.          Your exucutable file  will be named mustest.exe.  You may use
  365.          any of the compiler/linker options that you wish.
  366.  
  367.          Should you  have the files  in other directories,  other than
  368.          the  default Power  C directory,  make sure  you include  the
  369.          proper DOS paths in the compiler and linker command line, ie;
  370.  
  371.  
  372.          pc \c_work\mustest.c
  373.          pcl \c_work\mustest ;\compinc\mouspc13.mix
  374.  
  375.  
  376.          Lastly,  make sure  that  your  program source  includes  the
  377.          proper header files and any dos path to them. As an example;
  378.  
  379.  
  380.          #include <cesjoy.h>  (if in the  current Power  C directory),
  381.          or;
  382.  
  383.          #include  <\c_work\cesmouse.h> (if  the file  is  not in  the
  384.          default Power C directory).
  385.  
  386.  
  387.          These include files  contain the function prototypes  and any
  388.          declarations for extern variables.
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                                        4
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.                             COMPILING WITH QUICK C
  402.  
  403.  
  404.  
  405.          To compile  your programs  with the  CESmouse or  CESjoystick
  406.          libraries with Quick C is a little more time consuming.
  407.  
  408.          Each of the library modules for  Quick C follow the following
  409.          format:
  410.  
  411.  
  412.          mouseqcX.lib (for mouse functions) or;
  413.  
  414.          joyqcX.lib (for joystick functions)
  415.  
  416.  
  417.          The "qc" included in the file name stands for Quick C and the
  418.          X stands for  the memory model. At the present  time, the CES
  419.          mouse  and joystick  libraries only  support  version 1.0  of
  420.          Quick C. However, there should be little problem in using the
  421.          compiled libraries  with the newer  versions of Quick  C. The
  422.          CES mouse  and joystick libraries  support all of  the memory
  423.          models supplied with Quick C version 1.0.
  424.  
  425.          The easiest way to compile and  link your Quick C programs is
  426.          as follows;
  427.  
  428.  
  429.          qcl /As mustest.c  /link mouseqcs.lib; (and any  other needed
  430.          libraries) This is a compiled small memory model executable.
  431.  
  432.  
  433.          If you seperatly compile and link your file, you may now link
  434.          the file using standard linker syntax.
  435.  
  436.  
  437.          link mustest,,,mousqc1s.lib;
  438.  
  439.  
  440.          Your exucutable file  will be named mustest.exe.  You may use
  441.          any of the compiler/linker options that you wish.
  442.  
  443.          Should you  have the files  in other directories,  other than
  444.          the  default Quick  C directory,  make sure  you include  the
  445.          proper DOS paths in the compiler and linker command line, ie;
  446.  
  447.  
  448.          qcl /As /c \c_work\mustest.c    (/c = compile only)
  449.          link  \c_work\mustest,,,\compinc\mousecs.lib;
  450.  
  451.  
  452.          Lastly,  make sure  that  your  program source  includes  the
  453.          proper header files and any dos path to them. As an example;
  454.  
  455.  
  456.          #include <cesjoy.h> (if in the  current Quick C directory and
  457.          PATH), or;
  458.  
  459.  
  460.                                        5
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.          #include  "\c_work\cesmouse.h" (if  the file  is  not in  the
  468.          default Quick  C directory.  Make sure that  LIB=  is  set in
  469.          your autoexec.bat).
  470.  
  471.          These include files  contain the function prototypes  and any
  472.          declarations for external variables.
  473.  
  474.          The  Quick  C and  MSC,  optimizing  compiler, use  the  same
  475.          command  line syntax,  except that  the MSC  version uses  CL
  476.          instead of the Quick C command line syntax of QCL.
  477.  
  478.          The library names for MicroSoft C 6.0 are;
  479.  
  480.          mousemsX.lib, where X  is the memory model and  the ms stands
  481.          for MicroSoft. The tiny and small  libraries are the same, so
  482.          use the small,  and the large and  huge are the same,  so use
  483.          the large model when linking.
  484.  
  485.          A Microsoft C example would be;
  486.  
  487.          cl /AL /Ot mustest.c        (large model)
  488.          link mustest.c,,,mouusemsl.lib
  489.  
  490.          Remember to  use the /A option  to specify the  proper memory
  491.          model, ie /As or /Al, etc.  Use the proper CES library memory
  492.          model denoted by  the s through l  at the end of  the library
  493.          name and lastly make sure you  have included in your setup of
  494.          Quick C,  version 1.0, all of  the needed memory  models that
  495.          you will use. Newer versions of Quick  C allow you to use all
  496.          the memory models from the interactive environment.
  497.  
  498.  
  499.          MAKING A QUICK LIBRARY OF THE CES FUNCTIONS
  500.  
  501.  
  502.          If you  wish to  make a  Quick Library  of the  CES Mouse  or
  503.          Joystick  functions, the  following  command  line syntax  is
  504.          provided.
  505.  
  506.  
  507.          link \lib\quicklib+mouseqcm.lib,mouseqcm.qlb /I /Q;
  508.  
  509.          link \lib\quicklib+joyqcm.lib,joyqcm.qlb /I /Q;
  510.  
  511.  
  512.          The /I option displays linker information as the linker links
  513.          the library into a Quick Library, the /Q option.
  514.  
  515.          By making a  Quick Library, you can use the  CES functions in
  516.          the interactive environment, but the library is put in RAM at
  517.          the time  you load qc,  so you have  less room in  memory for
  518.          your compiled programs.
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.                                        6
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.                             COMPILING WITH TURBO C
  534.  
  535.  
  536.  
  537.          To compile  your programs  with the  CESmouse or  CESjoystick
  538.          libraries with Borlands Turbo C is easy.
  539.  
  540.          Each of the library modules for  Turbo C follow the following
  541.          format:
  542.  
  543.  
  544.          mousetcX.lib   (for mouse functions) or;
  545.  
  546.          joytcX.lib     (for joystick functions)
  547.  
  548.  
  549.          The "tc" of  course stands for Turbo  C and the X  stands for
  550.          the memory model being used which is either "s" for the small
  551.          memory model, "m" for the medium memory model, and so on. All
  552.          of the memory models are fully supported in the libraries.
  553.  
  554.          The  easiest  way   to  compile  your  programs   within  the
  555.          interactive environment  of Turbo  C for  all versions  is to
  556.          create a  a project  file and include  it in  the interactive
  557.          environment. An  example would be  for the  following project
  558.          file, mustest.prj;
  559.  
  560.  
  561.          mustest.c
  562.          mousets.lib
  563.  
  564.  
  565.          This project file will compile the source file, mustest.c and
  566.          include the small  mouse library for version 2.0  of Turbo C.
  567.          The executable file will be named mustest.exe.
  568.  
  569.          Should you  have the files  in other directories,  other than
  570.          the default  Turbo C directories,  make sure you  include the
  571.          proper DOS paths in the project file, ie;
  572.  
  573.  
  574.          \c_work\mustest.c
  575.          \complibs\moustcs.lib
  576.  
  577.  
  578.          Lastly,  make sure  that  your  program source  includes  the
  579.          proper header files and any dos path to them. As an example;
  580.  
  581.  
  582.          #include <cesjoy.h>  (if in the  current Turbo  C directory),
  583.          or;
  584.  
  585.          #include  "\c_work\cesmouse.h" (if  the file  is  not in  the
  586.          default Turbo C directory).
  587.  
  588.          The include  files contain  the function  prototypes and  any
  589.          declarations for extern variables.
  590.  
  591.  
  592.                                        7
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.          If you use the Turbo C command line compiler, you may compile
  600.          your programs  with these libraries  in the  following manner
  601.          which assumes that  all of the compiler libraries  are in the
  602.          proper Turbo C subdirectories.
  603.  
  604.  
  605.          tcc -ms mustest.c moust20s.lib
  606.  
  607.  
  608.          Any of the  allowable compiler/linker options can  be used. A
  609.          recommended set of options would be -G for size optimization,
  610.          and of  course the -ms  tells the  compiler to use  the small
  611.          memory model  and of course you  must use the  small library,
  612.          mousetcs.lib.
  613.  
  614.          The Turbo C++ compiler is identical to the Turbo C compiler
  615.          and the libraries are fully functional with the new Turbo C++
  616.          when compiling a standard C program.
  617.  
  618.          The new Borland C++ compiler syntax is identical except that
  619.          the command line compiler is bcc instead of tcc. All other
  620.          options are the same and the libraries are fully functional
  621.          as is with Borland C++.
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                                        8
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.                           COMPILING WITH QUICK BASIC
  666.  
  667.  
  668.  
  669.          To compile your programs with the CESmouse library with Quick
  670.          Basic is as easy as compiling your C programs with Quick C.
  671.  
  672.          The library  module is  the MicroSoft  Quick C  medium memory
  673.          library and it has the following format;
  674.  
  675.  
  676.          mouseqcm.lib
  677.  
  678.  
  679.          The easiest way to compile and link your Quick Basic programs
  680.          is separately  using the command  line syntax.  First compile
  681.          your Quick  Basic program  using any of  the QB  command line
  682.          options, such as;
  683.  
  684.  
  685.          qb moustest.bas     (source is not included, example only)
  686.  
  687.  
  688.          Next, you must link your  compiled file, now moustest.obj, as
  689.          follows;
  690.  
  691.  
  692.          link moustest,,,brun40.lib mouseqcm.lib
  693.  
  694.  
  695.          The above  example will  create moustest.exe,  a stand  alone
  696.          executable  program. If  you eliminate  brun40.lib, you  must
  697.          have  brun40.exe on  the disk  or in  the path  when you  run
  698.          moustest.exe. The .lib extensions can be omitted.
  699.  
  700.          One thing to remember is ALWAYS  put mousqbc4.lib LAST on the
  701.          command line. Quick Basic must search BASIC libraries first.
  702.  
  703.          Should you have the files and libraries in other directories,
  704.          other than the  default Quick Basic directory,  make sure you
  705.          include  the proper  DOS  paths in  the  compiler and  linker
  706.          command line, ie;
  707.  
  708.  
  709.          qb \bas_work\moustest.bas
  710.          link \bas_work\moustest,,,\baslibs\mouseqcm.lib
  711.  
  712.  
  713.  
  714.          Another alternative is to list  the needed directories in the
  715.          Quick Basic  LIB environment variable.  See your  Quick Basic
  716.          reference manual for instructions on setting this environment
  717.          variable.
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.                                        9
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.          Lastly, make sure that your Basic programs include the header
  732.          file, cesmouse.bas, and any paths to it. As an example;
  733.  
  734.  
  735.          REM $INCLUDE 'cesmouse.bas'   or,
  736.          ' $INCLUDE '\bas_work\cesmouse.bas'
  737.  
  738.  
  739.          The metacommand $INCLUDE must be on a REMark line.
  740.  
  741.          Remember that the sample include  file, cesmouse.bas, is only
  742.          an example for you to expand upon. Quick Basic useage of this
  743.          C library is not supported.
  744.  
  745.  
  746.  
  747.          MAKING A QUICK BASIC LIBRARY OF THE CES MOUSE FUNCTIONS
  748.  
  749.  
  750.          If  you  wish to  make  a  Quick  Library  of the  CES  Mouse
  751.          functions, the following command line syntax is provided, (as
  752.          well as a batch, (.BAT), file on the distribution disk);
  753.  
  754.  
  755.          link /Q mouseqcm.lib,mousqbc4.qlb,,bqlb40.lib;
  756.  
  757.          Other link options,  such as /I, can be used.  (The /I option
  758.          gives you information as you link the file).
  759.  
  760.          By  making  a  Quick  Library, you  can  use  the  CES  Mouse
  761.          functions in the interactive environment,  but the library is
  762.          put in  RAM at the  time you load  qb, by specifying  a quick
  763.          library. You will have less room  in memory for your compiled
  764.          programs.
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.                                       10
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.                                 MOUSE FUNCTIONS
  798.  
  799.  
  800.          The mouse  function header  or include  file consists  of the
  801.          following function definitions,  which can be seen  by typing
  802.          from the command line;
  803.  
  804.          C>type cesmouse.h
  805.  
  806.  
  807.          /*  Mouse functions header file  */
  808.          /*  Copyright 1989, 1991, Computer Engineering Services */
  809.  
  810.          void showmouse(void);
  811.          void hidemouse(void);
  812.          void posmouse(int mouseX, int mouseY);
  813.          void setmousetrack(int Xtrack, int Ytrack);
  814.          void setmousespeed(int speed);
  815.          void mousegraphcurs(int hspot, int vspot, int cursor);
  816.          void mousetextcurs(int curstype, int scrnmask, int cursmask);
  817.          void penemulON(void);
  818.          void penemulOFF(void);
  819.          void cagemouse(int ulX, int ulY, int lrX, int lrY);
  820.          void cagehoriz(int lft, int rgt);
  821.          void cagevert(int top, int bot);
  822.          void mousewindoff(int ulX, int ulY, int lrX, int lrY);
  823.          void savemousedrvr(int *mdrvrbuff);
  824.          void restoremousedrvr(int *mdrvrbuff);
  825.          void setcrtpage(int page);
  826.          void assignmbtn(int btn, int key);
  827.          void setlang(int lang);
  828.          void enablemdrvr(void);
  829.          void setallscales(int Xtrack, int Ytrack, int speed);
  830.  
  831.          int resetmouse(void);
  832.          int mousedrvr(void);
  833.          int buttons(void);
  834.          int lftbutton(void);
  835.          int ctrbutton(void);
  836.          int rgtbutton(void);
  837.          int mousecursX(void);
  838.          int mousecursY(void);
  839.          int sensemouse(int ulX, int ulY, int lrX, int lrY);
  840.          int sensetop(int top);
  841.          int sensebottom(int bottom);
  842.          int senseleft(int left);
  843.          int senseright(int right);
  844.          int mousetrackX(void);
  845.          int mousetrackY(void);
  846.          int getmousespeed(void);
  847.          int getmouseBPXinfo(int button);
  848.          int getmouseBPYinfo(int button);
  849.          int getmouseBRXinfo(int button);
  850.          int getmouseBRYinfo(int button);
  851.          int mouseXcnt(void);
  852.          int mouseYcnt(void);
  853.          int getmdrvrstorage(void);
  854.  
  855.  
  856.                                       11
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.          int getcrtpage(void);
  864.          int disablemdrvr(void);
  865.          int getmversion(void);
  866.          int getmtype(void);
  867.          int getmirq(void);
  868.          int mdrvrreset(void);
  869.          int getlang(void);
  870.  
  871.          int lastMX, lastMY, Xcount, Ycount, btnrel, btnpress, mbtns;
  872.  
  873.  
  874.          There are several global variables  defined in the cesmouse.h
  875.          mouse header file so you need to ensure that your programs do
  876.          not use those variable names, which are;
  877.  
  878.          lastMX
  879.          lastMY
  880.          Xcount
  881.          Ycount
  882.          btnrel
  883.          btnpress
  884.          mbtns
  885.  
  886.  
  887.          All  of your  programs  that will  use  mouse functions  must
  888.          include the cesmouse.h header of include file, such as;
  889.  
  890.          #include <cesmouse.h>
  891.  
  892.          and any path to the file such as;
  893.  
  894.          #include "\c_work\cesmouse.h"
  895.  
  896.          The example C  source code throughout this  chapter summarize
  897.          all of the  functions, usage and global  variables. The first
  898.          few functions are  the most commonly used and  right after is
  899.          the first example C source code.
  900.  
  901.  
  902.          void showmouse(void);
  903.  
  904.          This  function displays  the mouse  cursor  at the  positions
  905.          specified  by posmouse().  If  posmouse()  is not  used,  the
  906.          defaults are assumed and the mouse cursor is displayed in the
  907.          center of your screen.
  908.  
  909.  
  910.          void hidemouse(void);
  911.  
  912.          When this  function is called,  the mouse  cursor disappears.
  913.          You can make it reappear by using showmouse().
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                                       12
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.          void posmouse(int mouseX, int mouseY);
  930.  
  931.          The posmouse function  will position the mouse  cursor at the
  932.          mouseX, or X coordinate and at the mouseY, or Y coordinate on
  933.          your  screen. You  can move  the  mouse cursor  all over  the
  934.          screen by using this function.
  935.  
  936.          If you  are programming an  application for an  eighty column
  937.          text screen,  multiply the row and  column by eight,  (8), to
  938.          get the  proper screen position.  The following  example will
  939.          position  the text  mouse  cursor at  screen  position row  5
  940.          column 39;
  941.  
  942.          posmouse((8 * 39), (8 * 5));
  943.  
  944.          In graphics mode,  simply specify the proper  coordinate. 0,0
  945.          is always the upper left hand corner.
  946.  
  947.  
  948.          void setmousetrack(int mouseX, int mouseY);
  949.  
  950.          This function sets the tracking ratio or scaling of the mouse
  951.          in both the X and the Y axis.
  952.  
  953.  
  954.          void setmousespeed(int speed);
  955.  
  956.          This function sets  the double speed threshold  of the mouse.
  957.          By setting  this number  higher, the  mouse cursor  will move
  958.          more quickly across the screen. The  useful range seems to be
  959.          between 300 and 900.
  960.  
  961.  
  962.          void setmousegraphcurs(int hspot, int vspot, int cursor);
  963.  
  964.          This function sets  the mouse graphics cursor  to a different
  965.          shape. Int hspot  and int vspot is  the X and Y  hot spot, or
  966.          the main focal  point of the cursor in pixels.  Int cursor is
  967.          the defined  cursor. To define the  cursor, one must  keep in
  968.          mind the cursor screen mask, or I  like to think of it as the
  969.          "shadow" and the cursor mask,  which is actually the complete
  970.          outline of the cursor. The following is given as an example;
  971.  
  972.          static int hand[] =
  973.          {
  974.          /* cursor screen mask */
  975.  
  976.             0xE1FF       /* 1110000111111111 */
  977.             0xE1FF       /* 1110000111111111 */
  978.             0xE1FF       /* 1110000111111111 */
  979.             00E1FF       /* 1110000111111111 */
  980.             0xE1FF       /* 1110000111111111 */
  981.             0xE000       /* 1110000000000000 */
  982.             0xE000       /* 1110000000000000 */
  983.             0xE000       /* 1110000000000000 */
  984.             0x0000       /* 0000000000000000 */
  985.             0x0000       /* 0000000000000000 */
  986.  
  987.  
  988.                                       13
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.             0x0000       /* 0000000000000000 */
  996.             0x0000       /* 0000000000000000 */
  997.             0x0000       /* 0000000000000000 */
  998.             0x0000       /* 0000000000000000 */
  999.             0x0000       /* 0000000000000000 */
  1000.             0x0000       /* 0000000000000000 */
  1001.  
  1002.             /* cursor mask */
  1003.  
  1004.             0x1E00       /* 0001111000000000 */
  1005.             0x1200       /* 0001001000000000 */
  1006.             0x1200       /* 0001001000000000 */
  1007.             0x1200       /* 0001001000000000 */
  1008.             0x1200       /* 0001001000000000 */
  1009.             0x13FF       /* 0001001111111111 */
  1010.             0x1249       /* 0001001001001001 */
  1011.             0x1249       /* 0001001001001001 */
  1012.             0x1249       /* 0001001001001001 */
  1013.             0xF249       /* 1111001001001001 */
  1014.             0x9001       /* 1001000000000001 */
  1015.             0x9001       /* 1001000000000001 */
  1016.             0x9001       /* 1001000000000001 */
  1017.             0x8001       /* 1000000000000001 */
  1018.             0x8001       /* 1000000000000001 */
  1019.             0x8001       /* 1000000000000001 */
  1020.             0xFFFF       /* 1111111111111111 */
  1021.          };
  1022.  
  1023.             /* set the hspot to 5 and the vspot top 0 */
  1024.             /* and set the cursor */
  1025.  
  1026.          mousegraphcurs(5,0,*hand);
  1027.  
  1028.          A bit complex, but  can be done if you can  convert binary to
  1029.          hexadecimal. A piece of graph paper is really handy.
  1030.  
  1031.  
  1032.          void setmousetextcurs(int curstype, int scrnmask, int
  1033.          cursmask);
  1034.  
  1035.          This function is used to set the mouse cursor in text mode as
  1036.          either a software  cursor, (int curstype =  0), or  as a hard
  1037.          ware cursor, (int  curstype = 1), as well  as the foreground,
  1038.          background colors, whether the cursor blinks or doesn't.
  1039.  
  1040.          The following sets the text cursor so that it will invert the
  1041.          forground and background colors;
  1042.  
  1043.          setmousetextcurs(0,0xFFFF,0x7700);
  1044.  
  1045.          The following turns OFF the hardware cursor;
  1046.  
  1047.          setmousetextcurs(1,16,0);
  1048.  
  1049.          Note the use of both decimal and hex which is OK.
  1050.  
  1051.          The full  use of  the hardware and  software text  cursors is
  1052.  
  1053.  
  1054.                                       14
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.          beyond the scope of this  library. For further information on
  1062.          both  graphics and  text cursors,  please  see the  Microsoft
  1063.          Mouse Programmers Reference.
  1064.  
  1065.          void penemulON(void);
  1066.          void penemulOFF(void);
  1067.  
  1068.          By default,  the mouse  emulates a lightpen  and can  be used
  1069.          with programs  that once upon a  time used light  pens. These
  1070.          functions can turn such emulation on or off.
  1071.  
  1072.  
  1073.          void cagemouse(int ulX, int ulY, int lrX, int lrY);
  1074.  
  1075.          This  function will  "cage the  mouse"  within the  specified
  1076.          screen coordinates  which make  sort of  a "window"  of mouse
  1077.          movement.  ulX and  ulY are  the upper  left X  and Y  screen
  1078.          coordinates  and lrX  and lrY  are the  lower right  X and  Y
  1079.          coordinates.
  1080.  
  1081.  
  1082.          void cagehoriz(int lft, int rgt);
  1083.          void cagevert(int top, int bot);
  1084.  
  1085.          These functions keep the mouse from going above, or below, or
  1086.          to the  left or  to the right  of the  specified coordinates.
  1087.          cagemouse uses  these routines  to cage  the mouse  within an
  1088.          entire "window".
  1089.  
  1090.  
  1091.          void mousewindoff(int ulX, int ulY, int lrX, int lrY);
  1092.  
  1093.          This function is similar to cagemouse, but when the limits of
  1094.          the  defined  "window  are exceeded,  the  mouse  turns  off.
  1095.          Showmouse must be called to make  the mouse reappear. Set the
  1096.          coordinates of where you want the mouse to appear first using
  1097.          posmouse.
  1098.  
  1099.  
  1100.          void savemousedrvr(int *mdrvrbuff);
  1101.          void restoremousedrvr(int *mdrvrbuff);
  1102.          int getmdrvrstorage(void);
  1103.  
  1104.          These functions are  used to save the  mouse driver variables
  1105.          and to  restore the mouse driver  variables. You can  get the
  1106.          size of  a buffer needed  by calling get  mdrvrstorage(); and
  1107.          then create a  buffer dimensioned to the needed  size and and
  1108.          then  call  the  above  functions  with  a  pointer  to  your
  1109.          dimensioned buffer. An example;
  1110.  
  1111.          int mousebuff[getmdrvrstorage()];
  1112.          savemousedrvr(*mousebuff);
  1113.          {
  1114.              other code
  1115.          {
  1116.          restoremousedrvr(*mousebuff);
  1117.  
  1118.  
  1119.  
  1120.                                       15
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.          void setcrtpage(int page);
  1128.          int getcrtpage(void);
  1129.  
  1130.          This function  sets the virtual  screen page number  that the
  1131.          mouse  is  functioning   on.  This  is  useful   in  graphics
  1132.          programming where numerous  pages can be stored  and used via
  1133.          hardware. The function getcrtpage  returns the current screen
  1134.          page.
  1135.  
  1136.  
  1137.          void assignmbtn(int btn, int key);
  1138.  
  1139.          This function will assign a  mouse button a specific keyboard
  1140.          key, such as 13, (a carriage return and line fees), when that
  1141.          specified button is pressed, or  combination of buttons. This
  1142.          function uses the  buttons() function and the  character must
  1143.          be specified in  ASCII. The character is  printed to standard
  1144.          out.
  1145.  
  1146.  
  1147.          void setlang(int lang);
  1148.  
  1149.          This function is only useful with the genuine Microsoft Mouse
  1150.          Driver and  sets the foreign  language useage of  that driver
  1151.          for its messages. The following is a summation;
  1152.  
  1153.          0 = English
  1154.          1 = French
  1155.          2 = Dutch
  1156.          3 = German
  1157.          4 = Swedish
  1158.          5 = Finnish
  1159.          6 = Spanish
  1160.          7 = Portuguese
  1161.          8 = Italian
  1162.  
  1163.  
  1164.          void enablemdrvr(void);
  1165.          int disablemdrvr(void);
  1166.  
  1167.          These  functions enable,  (enablemdrvr();)  the mouse  driver
  1168.          after a  call to disablemdrvr().  When you disable  the mouse
  1169.          driver,  the  mouse  will  not  work  at  all.  The  function
  1170.          disablemdrvr(); returns either a  1 for successful completion
  1171.          or  a  0 for  unsuccessful  completion  or disabling  of  the
  1172.          driver.
  1173.  
  1174.  
  1175.          void setallscales(int Xtrack, int Ytrack, int speed);
  1176.  
  1177.          This function sets all of the scales for the mouse within one
  1178.          function.  This   is  a  combination  of   setmousetrack  and
  1179.          setmousespeed.
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.                                       16
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.          int mousedrvr(void);
  1194.  
  1195.          This function  should be the  first mouse function  called in
  1196.          your program  to check and see  if the mouse driver  has been
  1197.          loaded.  If the  driver is  present in  memory, the  function
  1198.          returns an integer value of 1, or  true. If the driver is not
  1199.          present in memory, the integer value returned is 0, or false.
  1200.  
  1201.  
  1202.          int resetmouse(void);
  1203.  
  1204.          This function should be the  first, and almost last, function
  1205.          called  in your  program.  This function  resets  all of  the
  1206.          values of  the mouse  driver to their  default values  and it
  1207.          also returns  the number of  mouse buttons available  on your
  1208.          mouse. This  value is usually 2  or 3 as the  MicroSoft Mouse
  1209.          has  two buttons,  while the  Kraft Mouse,  and others,  have
  1210.          three buttons. This value is set in global variable mbtns.
  1211.  
  1212.          The standard defaults for most  mouse drivers are positioning
  1213.          the  cursor in  the  center of  the  screen  with a  standard
  1214.          reverse video software  cursor, and a slanted  graphics arrow
  1215.          cursor in graphics mode with light pen emulation on.
  1216.  
  1217.          This function is  equal to Mouse Function 0  in the MicroSoft
  1218.          Mouse Programmers Reference  Manual (as well as  others mouse
  1219.          programmers manuals). For other  default values, please refer
  1220.          to the MicroSoft Mouse Driver Programmers Reference Manual as
  1221.          well as other mouse driver manuals  as there are subtle, (yet
  1222.          usually negligible), differences.
  1223.  
  1224.  
  1225.          int buttons(void);
  1226.  
  1227.          This function returns an integer value  of between 0 and 7. A
  1228.          0 means that no button were  pushed. On a three button mouse,
  1229.          the  left button  will return  a  1. The  center button  will
  1230.          return a 4 and the right button  will return a 2. If you push
  1231.          a couple  buttons, the  values are  added. All  three buttons
  1232.          pushed will return 7.
  1233.  
  1234.  
  1235.          int lftbutton(void);
  1236.  
  1237.          This function will  return a 1 when the left  mouse button is
  1238.          pushed.
  1239.  
  1240.  
  1241.          int ctrbutton(void);
  1242.  
  1243.          This  function will  return a  1  when the  center button  is
  1244.          pushed.
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.                                       17
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.          int rgtbutton(void);
  1260.  
  1261.          This  function will  return  a 1  when  the  right button  is
  1262.          pushed.
  1263.  
  1264.  
  1265.          int mousecursX(void);
  1266.  
  1267.          This function  returns the X,  (horizontal), position  of the
  1268.          mouse cursor.  When in  eighty column  text mode,  divide the
  1269.          returned value  by 8  to get  the cursor  location. In  forty
  1270.          column mode, divide the number  by 16. Otherwise, in graphics
  1271.          mode,  the number  returned is  the position.  This value  is
  1272.          stored in the global variable lastMX.
  1273.  
  1274.  
  1275.          int mousecursY(void);
  1276.  
  1277.          This  function returns  the Y,  (vertical),  position of  the
  1278.          mouse  cursor.  All  of  the returns  are  the  same  as  for
  1279.          mousecursX(). This  value is  stored in  the global  variable
  1280.          lastMY.
  1281.  
  1282.  
  1283.          int sensemouse(int ulX, int ulY, int lrX, int lrY);
  1284.          int sensetop(int top);
  1285.          int sensebottom(int bottom);
  1286.          senseleft(int left);
  1287.          senseright(int right)
  1288.  
  1289.  
  1290.          These functions all return either a 0 for NOT being past that
  1291.          specified portion of  the screen and a 1 should  they be past
  1292.          the specified portions or coordinates of the screen.
  1293.  
  1294.          The function sensemouse sets up a window specified by ulX and
  1295.          ulY, the upper  left and right coordinates, and  lrX and lrY,
  1296.          the lower right X and Y coordinates.
  1297.  
  1298.          The other  return the same when  either top, bottom,  left or
  1299.          right are specified.
  1300.  
  1301.          int mousetrackX(void);
  1302.          int mousetrackY(void);
  1303.          int getmousespeed(void);
  1304.  
  1305.          These functions  return the tracking,  scaling or  the double
  1306.          speed threshold of the mouse as previously set.
  1307.  
  1308.  
  1309.          int getmouseBPXinfo(int button);
  1310.          int getmouseBPYinfo(int button);
  1311.  
  1312.          These functions  return the X or  Y coordinates of  the mouse
  1313.          when  the  mouse  button,  1, 4,  or  2  as  specified  under
  1314.          buttons();, has been  pushed. The number of  times the button
  1315.          has been pushed is stored in the variable btnpress.
  1316.  
  1317.  
  1318.                                       18
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.          int getmouseBRXinfo(int button);
  1326.          int getmouseBRYinfo(int button);
  1327.  
  1328.  
  1329.          These  functions   are  identical   to  getmouseBPXinfo   and
  1330.          getmouseBPYinfo except that the  button releases are returned
  1331.          in global variable btnrel.
  1332.  
  1333.  
  1334.          int mouseXcount(void);
  1335.          int mouseYcount(void);
  1336.  
  1337.          These functions return the accumulated mouse counts since the
  1338.          last time any of these  functions was called. Negative number
  1339.          indicate leftward movement for the Xcount and upward movement
  1340.          for the  Ycount. These  values are  stored in  the associated
  1341.          variables xcount and ycount.
  1342.  
  1343.          NOTE... The  following functions  are only  available on  the
  1344.          genuine Microsoft Mouse Driver.
  1345.  
  1346.  
  1347.          int getmversion(void);
  1348.  
  1349.          This function returns  the mouse driver version  number. 6.10
  1350.          will return as 60789 or similar.
  1351.  
  1352.  
  1353.          int getmtype(void);
  1354.  
  1355.          This function will return the mouse type as follows;
  1356.  
  1357.          1 indicates a bus mouse
  1358.          2 indicates a serial mouse
  1359.          3 indicates an InPort mouse
  1360.          4 indicates a PS-2 mouse
  1361.          5 indicates an HP mouse
  1362.  
  1363.  
  1364.          int getmirq(void);
  1365.  
  1366.          This function  returns the hardware  interrupt being  used by
  1367.          the mouse and mouse driver.
  1368.  
  1369.  
  1370.          int mdrvrreset(void);
  1371.  
  1372.          This  function  ONLY  resets  the mouse  driver.  A  1  being
  1373.          returned means success and a 0 means a failure to reset.
  1374.  
  1375.  
  1376.          int getlang(void);
  1377.  
  1378.          This function returns the language being used as described in
  1379.          the functionsetlang();
  1380.  
  1381.  
  1382.  
  1383.  
  1384.                                       19
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.                       EXAMPLE C SOURCE FOR  MOUSE LIBRARY
  1392.  
  1393.  
  1394.  
  1395.          #include <conio.h>
  1396.          #include <stdlib.h>
  1397.          #include <cesmouse.h>
  1398.  
  1399.          main()
  1400.          {
  1401.          int lft,ctr,rgt,mx,my,but;
  1402.  
  1403.              cprintf("PC Mouse Test\n");
  1404.              cprintf("Press Any Key to Exit\n\n");
  1405.  
  1406.                 /* Check for the Mouse Driver */
  1407.                 if (mousedrvr() == 0)
  1408.                   {
  1409.                    cprintf("Mouse Driver Not Installed\n\n");
  1410.                       exit(1);
  1411.                   }
  1412.  
  1413.                 /* Reset the mouse.. All registers to '0'  */
  1414.                 resetmouse();
  1415.  
  1416.                 /* Position the Mouse  X = 40, Y = 12 */
  1417.                 posmouse(320,96);
  1418.  
  1419.                 /* Show the Mouse */
  1420.                 showmouse();
  1421.  
  1422.                 /* Output Mouse Button Values */
  1423.                 for(;;)
  1424.                         {
  1425.                         lft = lftbutton();
  1426.                         ctr = ctrbutton();
  1427.                         rgt = rgtbutton();
  1428.                         mx = mousecursX();
  1429.                         my = mousecursY();
  1430.                         but = buttons();
  1431.  
  1432.                         if (kbhit()) break;
  1433.                         }
  1434.                 /* Hide the Mouse */
  1435.                 hidemouse();
  1436.  
  1437.                 /* Reset the Mouse */
  1438.                 resetmouse();
  1439.  
  1440.              exit(0);
  1441.          }
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.                                       20
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.                                    JOYSTICKS
  1458.  
  1459.  
  1460.  
  1461.          Joysticks are  still used by  game players and  writers. They
  1462.          are dependant  on the  timing of  a one  shot pulse  into the
  1463.          joystick which is triggered by one of the joystick functions.
  1464.          The time it takes for a specific  bit  to go, after firing of
  1465.          the one shot pulse from a logical 0 to a logical 1, back to a
  1466.          logical 0 gives us the  approximate position of the joystick.
  1467.          This is  all dependant upon  the resistance in  the joystick,
  1468.          ie, the X-Y axis variable resistors in the joystick.
  1469.  
  1470.          The function fires  the one shot and  continuously checks the
  1471.          appropriate bit for X or Y or  joystick 1 or joystick 2. When
  1472.          it returns to a logical 0,  the function is exited. The time,
  1473.          or number returned, is actually  the number of iterations, or
  1474.          loops that the function performed prior to the bit going to a
  1475.          0. This number gives a relative position of the joystick. All
  1476.          the way to the right on the X axis returns the X axis highest
  1477.          number, while all  the way down on  the Y axis returns  the Y
  1478.          axis highest number.
  1479.  
  1480.          For the functions that read the X and Y axis of the joystick,
  1481.          remember: the value  returned is only a  relative positioning
  1482.          of the joystick. In the lower  values, 4 to 10 being returned
  1483.          is common.  The highest  values are  very dependant  upon the
  1484.          type and speed of your computer as  well as the speed of your
  1485.          compiled  program,   which  is  compiler   dependant.  Values
  1486.          returned can  be from 150 to  over 500, again  depending upon
  1487.          all the variables.
  1488.  
  1489.          Using Power C and  a 12 Mhz 286 machine, the  high end was in
  1490.          the mid hundreds.  Using Turbo C, the  higher values returned
  1491.          were in the five hundreds, so compilers are different.
  1492.  
  1493.          The IBM  AT and  compatibles have  routines written  in their
  1494.          bios which  will read the  joystick ports connected  to their
  1495.          bus.  Since there  is no  way  of knowing  what machine  your
  1496.          finished programs may  be run on, the  functions will operate
  1497.          in  the same  fashion on  any machine,  returning a  RELATIVE
  1498.          POSITIONING of the joystick along its X or Y axis.
  1499.  
  1500.          One of the first things that should be done in a program that
  1501.          uses the joysticks  is to call the getjoyAX  and getjoyAY, as
  1502.          well as the other two 'get' functions if a second joystick is
  1503.          to be  used, and ask  the user  to "CENTER YOUR  JOYSTICK AND
  1504.          PRESS ENTER", or similar routine. By  doing this, you can get
  1505.          the returned  value of the  center position of  the joystick,
  1506.          center X and center Y, and assign  them to a variable so that
  1507.          twice center X is at the far right, and twice center Y is all
  1508.          the way down. All the way up, Y  should be around 0 to 10 and
  1509.          all the way to the left, X should also be around 0 to 10.
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.                                       21
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.                               JOYSTICK FUNCTIONS
  1524.  
  1525.  
  1526.  
  1527.          The joystick  header or include  file simply consists  of the
  1528.          following, as can be seen by typing from the command line;
  1529.  
  1530.          C>type cesjoy.h
  1531.  
  1532.  
  1533.          /*  Joystick routines header file */
  1534.          /*  Copyright 1989 Computer Engineering Services */
  1535.  
  1536.  
  1537.          int getjoyAX(void);
  1538.          int getjoyAY(void);
  1539.          int getjoyAB1(void);
  1540.          int getjoyAB2(void);
  1541.          int getjoyBX(void);
  1542.          int getjoyBY(void);
  1543.          int getjoyBB1(void);
  1544.          int getjoyBB2(void);
  1545.          int joyport(void);
  1546.  
  1547.  
  1548.          There  are  no  global  variables  defined  in  the  cesjoy.h
  1549.          joystick header file. All of  your programs that will include
  1550.          joystick functions must include cesjoy.h, such as;
  1551.  
  1552.  
  1553.          #include <cesjoy.h>
  1554.  
  1555.          and any path to the file such as;
  1556.  
  1557.  
  1558.          #include <\c_work\cesjoy.h>
  1559.  
  1560.          The example C source code included at the end of this chapter
  1561.          summarizes all of the functions and useage.
  1562.  
  1563.  
  1564.          int joyport(void);
  1565.  
  1566.          This  function  checks to  see  if  a  game port  adapter  is
  1567.          included in the system bus.  Simply, this function checks the
  1568.          the lower byte at  location 201 hex and checks to  see if the
  1569.          top four  bits, bit  4, 5,  6, and 7  are at  a logic  1, and
  1570.          checks the bottom  four bits, 0, 1,  2, and 3 to  see if they
  1571.          are at  a logic  zero. If  all of  these conditions  are met,
  1572.          there  is a  gane  port adapter  installed  in  any class  of
  1573.          machineand returns  true or  a 1.  If there  is no  game port
  1574.          installed or should you have  a faulty joystick connected, or
  1575.          if a button is pressed, it will return a 0.
  1576.  
  1577.          This  function only  returns an  integer, either  a 1,  true,
  1578.          should a game port be installed, or a 0, false, should a game
  1579.          port not be installed or if  a button is pressed or defective
  1580.  
  1581.  
  1582.                                       22
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.          joystick is installed.
  1590.  
  1591.  
  1592.          int getjoyAX(void);
  1593.  
  1594.          This function  returns the relative  position of  the primary
  1595.          joystick, (if  you are  using only one,  this is  the primary
  1596.          joystick), along  its X axis.  Returns a lower  integer value
  1597.          when moved to the right and a  higher value when moved to the
  1598.          left.
  1599.  
  1600.  
  1601.          int getjoyAY(void);
  1602.  
  1603.          This function  returns the relative  position of  the primary
  1604.          joystick along its Y axis. Returns a lower integer value when
  1605.          moved to the top and a higher value when moved to the bottom.
  1606.  
  1607.  
  1608.          int getjoyAB1(void);
  1609.  
  1610.          This function returns  a 1 or true, when the  first button on
  1611.          the primary joystick is depressed.  Otherwise it returns a 0,
  1612.          or false, when the function is called.
  1613.  
  1614.  
  1615.          int getjoyAB2(void);
  1616.  
  1617.          This function returns a 1 or  true, when the second button on
  1618.          the primary joystick is depressed.  Otherwise it returns a 0,
  1619.          or false, when the function is called.
  1620.  
  1621.  
  1622.          int getjoyBX(void);
  1623.  
  1624.          This function is identical to  getjoyAX above, except returns
  1625.          the X value of the secondary joystick.
  1626.  
  1627.  
  1628.          int getjoyBY(void);
  1629.  
  1630.          This function is identical to  getjoyAY above, except returns
  1631.          the Y value of the secondary joystick.
  1632.  
  1633.  
  1634.          int getjoyBB1(void);
  1635.  
  1636.          This function is identical to getjoyAB1 above, except returns
  1637.          a 1, or  true, if the first button on  the secondary joystick
  1638.          is depressed.
  1639.  
  1640.  
  1641.          int getjoyBB2(void);
  1642.  
  1643.          This function is identical to getjoyAB2 above, except returns
  1644.          a 1, or true, if the  second button on the secondary joystick
  1645.          is depressed.
  1646.  
  1647.  
  1648.                                       23
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.                    EXAMPLE C SOURCE WITH JOYSTICK FUNCTIONS
  1656.                             Written for Mix Power C
  1657.  
  1658.  
  1659.          #include <dos.h>
  1660.          #include <bios.h>
  1661.          #include <conio.h>
  1662.          #include <cesjoy.h>
  1663.  
  1664.          int x, y, b1, b2, xx, yy, b3, b4;
  1665.  
  1666.          main()
  1667.          {
  1668.              clrscrn();
  1669.  
  1670.              if (joyport() == 0)
  1671.              {
  1672.                  printf("There is NO game port installed\n");
  1673.                  exit();
  1674.              }
  1675.              poscurs(19,20);
  1676.                 cprintf("PC Joy Stick Test, Copyright 1989 C.E.S.");
  1677.              poscurs(20,28);
  1678.                 cprintf("Press any key to exit.");
  1679.  
  1680.                 for(;;)
  1681.                         {
  1682.                         x = getjoyAX();
  1683.                         y = getjoyAY();
  1684.                         b1 = getjoyAB1();
  1685.                         b2 = getjoyAB2();
  1686.                         xx = getjoyBX();
  1687.                         yy = getjoyBY();
  1688.                         b3 = getjoyBB1();
  1689.                         b4 = getjoyBB2();
  1690.  
  1691.                  poscurs(5,10);
  1692.                  cprintf("Joystick #1. X= %3d", x);
  1693.                  poscurs(6,10);
  1694.                  cprintf("Joystick #1. Y= %3d", y);
  1695.                  poscurs(8,10);
  1696.                  cprintf("Joystick #1, Button #1= %1d", b1);
  1697.                  poscurs(9,10);
  1698.                  cprintf("Joystick #1, Button #2= %1d", b2);
  1699.                  poscurs(11,10);
  1700.                  cprintf("Joystick #2. X= %3d", xx);
  1701.                  poscurs(12,10);
  1702.                  cprintf("Joystick #2. Y= %3d", yy);
  1703.                  poscurs(14,10);
  1704.                  cprintf("Joystick #2, Button #1= %1d", b3);
  1705.                  poscurs(15,10);
  1706.                  cprintf("Joystick #2, Button #2= %1d", b4);
  1707.                         if (kbhit()) break;
  1708.                         }
  1709.  
  1710.              clrscrn();
  1711.          }
  1712.  
  1713.  
  1714.                                       24
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.                                   BUG REPORT
  1722.  
  1723.  
  1724.  
  1725.          Please fill  out the  following form to  report and  bugs. If
  1726.          possible, also send a copy of your C source where the bug has
  1727.          occurred. I  do not think that  the library contains  any any
  1728.          bugs, which may  be a bold statement, but it  has undergone a
  1729.          lot of testing. Please mail the completed for to:
  1730.  
  1731.          Computer Engineering Services
  1732.          P.O. Box 1222
  1733.          Show Low, Arizona  85901-1222
  1734.  
  1735.          ------------------------------------------------------------
  1736.  
  1737.          Name ______________________________ Phone (___)_____________
  1738.  
  1739.          Address ___________________________ City ___________________
  1740.  
  1741.          State ___________ Zip __________ Library Version ___________
  1742.  
  1743.          Compiler _____________ Version ____________
  1744.  
  1745.          Describe the bug or malfunction:
  1746.  
  1747.          ____________________________________________________________
  1748.  
  1749.          ____________________________________________________________
  1750.  
  1751.          ____________________________________________________________
  1752.  
  1753.          ____________________________________________________________
  1754.  
  1755.          What compiler directives or options were used:
  1756.  
  1757.          ____________________________________________________________
  1758.  
  1759.          ____________________________________________________________
  1760.  
  1761.          What linker options were used:
  1762.  
  1763.          ____________________________________________________________
  1764.  
  1765.          ____________________________________________________________
  1766.  
  1767.          Is your C source code enclosed? ______
  1768.  
  1769.          Other comments: ____________________________________________
  1770.  
  1771.          ____________________________________________________________
  1772.  
  1773.          ____________________________________________________________
  1774.  
  1775.          ____________________________________________________________
  1776.  
  1777.  
  1778.  
  1779.  
  1780.                                       25
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.                           REGISTRATION AND ORDER FORM
  1788.  
  1789.  
  1790.          Name _______________________________ Phone (___)____________
  1791.  
  1792.          Address ____________________________ City __________________
  1793.  
  1794.          State _________ Zip ___________ Bus. Phone (___)____________
  1795.  
  1796.          SHIPPING ADDRESS ___________________________________________
  1797.  
  1798.          City _________________________ State _________ Zip _________
  1799.  
  1800.  
  1801.          ------------------------------------------------------------
  1802.  
  1803.                 CESMouse Tools Library With Joystick Functions
  1804.  
  1805.  
  1806.          __ Registration of Shareware Only Version ........... $10.00
  1807.  
  1808.          __ Registration and Upgrade to Professional Library . $22.50
  1809.  
  1810.          __ Professional Library Updates ..................... $ 7.50
  1811.             (Registered Professional Library Users Only)
  1812.  
  1813.          __ Three inch Diskette .............................. $ 1.50
  1814.             (Default is 5.25 inch 360 K media)
  1815.  
  1816.  
  1817.  
  1818.          TOTAL ............................................. ________
  1819.  
  1820.          __ Personal Check       __ Money Order   is enclosed.
  1821.  
  1822.              Please make checks payable to John F. Jarrett, C.E.S.
  1823.          ------------------------------------------------------------
  1824.                                   PLEASE NOTE
  1825.  
  1826.          Personal  Checks take  two  to three  weeks  to clear.  Money
  1827.          Orders/Cashiers Checks are shipped  immediately. Please allow
  1828.          two weeks for delivery for regular mail, which is included in
  1829.          the prices above. Should we be  out of stock of something, we
  1830.          will spend  29 cents and send  you a notice and  the expected
  1831.          shipping date!
  1832.  
  1833.          When you  upgrade to the Professional  Library, all of  the C
  1834.          source for  all of the functions  is included,  plus  you get
  1835.          all of the additional mouse  functions for complete mouse and
  1836.          mouse cursor control PLUS a printed manual.
  1837.  
  1838.          Updates  is a  service  that will  send  you  updates to  the
  1839.          library for one year. I.E. bug fixes, new routines, etc.
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.                                       26
  1847.  
  1848.  
  1849.